<%@page pageEncoding="UTF-8" language="java" %>
<%@ include file="/commons/global.jsp"%>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="favicon.ico" >
<link rel="Shortcut Icon" href="favicon.ico" />
<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/respond.min.js"></script>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/h-ui.admin/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/css/style.css" />
<style type="text/css">
	.table-sort tr td{
	    text-align: center;
	}
	.dataTable td.sorting_1{
		background-color: inherit;
	}
	.mt_right {
    width: 100%;
}
</style>
</head>
<body>
		<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
			<span class="c-gray en">&gt;</span>
			培养方案管理
			<span class="c-gray en">&gt;</span>
			培养方案列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a> </nav>
		<div class="Hui-article">
			<article class="cl pd-20">
				<c:if test="${currentUser.type==2 }">
					<c:if test="${opstatus == 1 }">
						<div class="cl pd-5 bg-1 bk-gray mt-20">
							<span class="l"> <a href="javascript:;" id="add" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加方案</a> </span>
						</div>
					</c:if>
				</c:if>
				<div class="text-c">
					<form action="<%=request.getContextPath() %>/trainPlan/manager"  method="GET" id="pageForm">
						<input type="hidden" id="currentPage" name="currentPage" value="${currentPage }" >
						<input type="text" class="input-text" style="width:150px" placeholder="输入届数" id="enterterm" name="enterterm" value="${trainPlan.enterterm }">
						<select  class="mt_select" id="departId" name="depart.id">
							<option value="">---请选择系部---</option>
							<c:forEach var="dp" items="${departList}">
								<option  value="${dp.id}" ${dp.id == trainPlan.depart.id  ?'selected="selected"':''}>${dp.name}</option>
							</c:forEach>
						</select>
						<select  class="mt_select" id="majorId" name="major.id">
							<option value="">---请选择专业---</option>
							<c:forEach var="dp" items="${majorList}">
								<option  value="${dp.id}" ${dp.id == trainPlan.major.id  ?'selected="selected"':''}>${dp.name}</option>
							</c:forEach>
						</select>
						<select  class="mt_select" id="status" name="status">
							<option value="">---请选择状态---</option>
							<option value="0" ${ trainPlan.status==0?'selected="selected"':''}>---未审核---</option>
							<option value="1" ${ trainPlan.status==1?'selected="selected"':''}>---通过---</option>
							<option value="2" ${ trainPlan.status==2?'selected="selected"':''}>---退回---</option>
						</select>
						<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜方案</button>
					</form>
				</div>
				<!-- <div class="cl pd-5 bg-1 bk-gray mt-20">
					<span class="l"> <a href="javascript:;" id="datadel" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a href="javascript:;" id="add" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加方案</a> </span>
				</div> -->
				<div class="mt-20">
					<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th><input type="checkbox" name="" value=""></th>
						<th>届数</th>
						<th>培养方案名称</th>
						<th>创建人</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:if test="${trainPlanList == null or trainPlanList.size() == 0 }">
						<tr>
							<td colspan="6">没有记录</td>
						</tr>
					</c:if>
					<c:if test="${trainPlanList != null and trainPlanList.size() > 0 }">
						<c:forEach items="${trainPlanList }" var="trianPlan">
							<tr class="text-c">
								<td><input type="checkbox" value="${trianPlan.id }" class="ids" name=""></td>
								<td>${trianPlan.enterterm }届</td>
								<td>${trianPlan.name }</td>
								<td>${trianPlan.userVo.name }</td>
								<td>
									<c:if test="${trianPlan.status == 0}">
										未审核
									</c:if>
									<c:if test="${trianPlan.status == 1}">
										通过
									</c:if>
									<c:if test="${trianPlan.status == 2}">
										退回
									</c:if>
								</td>
								<td class="f-14 td-manage">
									<a style="text-decoration:none" class="ml-5" onClick="trainPlanDetail('查看方案信息','<%=request.getContextPath() %>/trainPlan/trainPlanDetail','${trianPlan.id }')" title="查看方案信息" >
										<i class="Hui-iconfont gray">&#xe665;</i>
									</a>
									<c:if test="${currentUser.type == 0}">
										<c:if test="${trianPlan.status == 0}">
											<a style="text-decoration:none" class="ml-5" onClick="trainPlanCheckYes(${trianPlan.id})" href="javascript:;" title="通过">
												<i class="Hui-iconfont gray">&#xe6a8;</i>
											</a>
											<a style="text-decoration:none" class="ml-5" onClick="trainPlanCheckNo('退回','<%=request.getContextPath() %>/trainPlan/trainPlanCheckNoUI','${trianPlan.id }')" href="javascript:;" title="退回">
												<i class="Hui-iconfont gray">&#xe706;</i>
											</a>
										</c:if>
									</c:if>
									<c:if test="${currentUser.type == 2}">
										<c:if test="${trianPlan.status == 0 || trianPlan.status == 2}">
										<c:if test="${opstatus == 1 }">
											<a style="text-decoration:none" class="ml-5" onClick="trainPlanDelete(${trianPlan.id})" href="javascript:;" title="删除">
												<i class="Hui-iconfont gray">&#xe6e2;</i>
											</a>
											<a style="text-decoration:none" class="ml-5" onClick="trainPlanUpdate('修改','<%=request.getContextPath() %>/trainPlan/trainPlanUpdateUI','${trianPlan.id }')" href="javascript:;" title="编辑">
												<i class="Hui-iconfont gray">&#xe6df;</i>
											</a>
										</c:if>
										</c:if>
										<c:if test="${trianPlan.status == 2}">
											<a style="text-decoration:none" class="ml-5" href="javascript:;" onClick="trainPlanCheckNoReason('退回原因','<%=request.getContextPath() %>/trainPlan/trainPlanCheckNoReason','${trianPlan.suggestion }')" title="退回原因：${trianPlan.suggestion}">
												<i class="Hui-iconfont gray">&#xe706;</i>
											</a>
										</c:if>
									</c:if>
								</td>
							</tr>
						</c:forEach>
					</c:if>
				</tbody>
			</table>
				</div>
			</article>
			<jsp:include page="/commons/page.jsp" />
		</div>

	<!--_footer 作为公共模版分离出去-->
	<!--_footer 作为公共模版分离出去-->
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/layer/2.4/layer.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/h-ui/js/H-ui.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/h-ui.admin/js/H-ui.admin.page.js"></script>
	<!--/_footer /作为公共模版分离出去-->

	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript">
        /*批量删除  */		 
   	 $("#datadel").click(function() {
   			var idChecks = $(".ids:checked");
   			if (idChecks.length == 0) {
   				top.layer.alert("请选择需要删除的记录！");
   				return false;
   			}
   			top.layer.confirm(
   			'您确认删除选中的记录吗?',
   			{
   				icon : 3,
   				title : '提示'
   			},
   			function() {

   				var id = "";
   				var ids = new Array();
   				for (var i = 0; i < idChecks.length; i++) {
   					id += idChecks[i].value
   							+ ",";
   					ids[i] = idChecks[i].value;
   				}
   				$.ajax({
   					url: "<%=request.getContextPath()%>/trainPlan/trainPlanDeleteIDs",
   					type: "post",
   					data: "ids="+ids,
   					dataType: "json",
   					success: function(data){
   						if(data.success){
   							top.layer.closeAll();
   							location.href="<%=request.getContextPath()%>/trainPlan/manager";
   						}else{
   							top.layer.open(
   								{
   									title: '删除',
   									content: "删除失败！有关联信息！",
   									icon:2
   							},function(index){
   								top.layer.close(index);
   							});
   						}
   					}
   				});
   			}); 
   		});
   	 $("#add").click(function(){
   		 var majorId = ${currentUser.majorId};
   		 var url  = '<%=request.getContextPath()%>/trainPlan/addUI';
		 index = layer.open({
				type: 2,
				title:"添加培养方案",
				content: url+"?majorId="+majorId
			});
			layer.full(index);
	 });

 	/* 查看 */
 	 function trainPlanDetail(title, url, id){
 			index = layer.open({
 				type: 2,
 				title: title,
 				content: url + "?id=" + id
 			});
 			layer.full(index);
 		}
	function trainPlanCheckNo(title, url, id){
			index = layer.open({
				type: 2,
				title: title,
				content: url + "?id=" + id
			});
			layer.full(index);
		}
	function trainPlanCheckNoReason(title, url, suggestion){
			index = layer.open({
				type: 2,
				title: title,
				content: url + "?suggestion=" + suggestion
			});
			layer.full(index);
		}
	function trainPlanUpdate(title, url, id){
		index = layer.open({
			type: 2,
			title: title,
			content: url + "?id=" + id
		});
		layer.full(index);
	}
	 /* 删除 */
	 function trainPlanCheckYes(id) {
			top.layer.confirm('您确认通过该方案吗?',
			{
				icon : 3,
				title : '提示'
			},
			function() {
				$.ajax({
					url: "<%=request.getContextPath()%>/trainPlan/trainPlanCheckYes",
					type: "post",
					data: {"id": id},
					dataType: "json",
					success : function(data){
						if(data.success){
							top.layer.closeAll();
							location.href="<%=request.getContextPath()%>/trainPlan/manager";
						}else{
							top.layer.open(
							{
								content: "通过失败！",
								icon:2
							},function(index){
								top.layer.close(index);
							});
						}
					}
				});
		});
	}
	 
	 function trainPlanDelete(id) {
			top.layer.confirm('您确认删除该条记录吗?',
			{
				icon : 3,
				title : '提示'
			},
			function() {
				$.ajax({
					url: "<%=request.getContextPath()%>/trainPlan/trainPlanDelete",
					type: "post",
					data: {"id": id},
					dataType: "json",
					success : function(data){
						if(data.success){
							top.layer.closeAll();
							location.href="<%=request.getContextPath()%>/trainPlan/manager";
						}else{
							top.layer.open(
							{
								title: '删除',
								content: "删除失败！有关联信息！",
								icon:2
							},function(index){
								top.layer.close(index);
							});
						}
					}
				});
		});
	}
	</script>
</body>
</html>